/**
 * Project Reactor
 */


#include "TcpServer.h"

/**
 * TcpServer implementation
 */


TcpServer::TcpServer(const string &ip,unsigned short port) 
:m_acceptor(ip,port)
,m_evt_loop(m_acceptor)
{
    
}

TcpServer::~TcpServer() {

}

void TcpServer::start() {
    m_acceptor.ready();
    m_evt_loop.loop();
}

void TcpServer::stop() {
    m_evt_loop.unloop();
}

void TcpServer::setAllCallback(TcpConnectionCallback &&tcc1,
    TcpConnectionCallback &&tcc2,TcpConnectionCallback &&tcc3) {
    m_evt_loop.setNewConnectionCallback(std::move(tcc1));
    m_evt_loop.setMessageCallback(std::move(tcc2));
    m_evt_loop.setCloseCallback(std::move(tcc3));

}